@echo off
echo 测试等待时间配置功能
echo.

echo 1. 检查当前配置...
echo 当前等待时间配置：
findstr "iot.automation.notification.wait.seconds" backend\src\main\resources\application.properties
echo.

echo 2. 修改配置为30秒（快速测试）...
powershell -Command "(Get-Content 'backend\src\main\resources\application.properties') -replace 'iot.automation.notification.wait.seconds=120', 'iot.automation.notification.wait.seconds=30' | Set-Content 'backend\src\main\resources\application.properties'"
echo 配置已修改为30秒等待时间
echo.

echo 3. 验证配置修改...
findstr "iot.automation.notification.wait.seconds" backend\src\main\resources\application.properties
echo.

echo 4. 启动后端服务...
cd backend
start /B mvn spring-boot:run
cd ..

echo 等待服务启动...
timeout /t 10 /nobreak > nul

echo 5. 测试自动化流程（使用30秒等待时间）...
curl -X POST http://localhost:8080/api/analysis/automation/full ^
  -H "Content-Type: application/json" ^
  -d "{\"username\":\"test\",\"password\":\"test\",\"deviceSn\":\"test123\",\"phone\":\"13800138000\"}"

echo.
echo 6. 恢复配置为120秒（生产环境推荐）...
powershell -Command "(Get-Content 'backend\src\main\resources\application.properties') -replace 'iot.automation.notification.wait.seconds=30', 'iot.automation.notification.wait.seconds=120' | Set-Content 'backend\src\main\resources\application.properties'"
echo 配置已恢复为120秒等待时间
echo.

echo 7. 验证配置恢复...
findstr "iot.automation.notification.wait.seconds" backend\src\main\resources\application.properties
echo.

echo 测试完成！
echo 如果看到日志中显示"等待30秒（从配置文件读取）"，说明配置功能正常工作。
echo 现在你可以通过修改配置文件来调整等待时间，无需修改代码。
pause
